﻿using AutoMapper;
using J.Model;
using J.ProductSet.Application.Command.ReleaseAppointmentCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.ReleaseAppointmentCommandHandler
{
    public class ReleaseAppointmentUpdateCommandHandler : IRequestHandler<ReleaseAppointmentUpdateCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public IMapper _mapper;
        public ReleaseAppointmentUpdateCommandHandler(ISqlSugarClient sqlSugarClient, IMapper mapper)
        {
            _sqlSugarClient = sqlSugarClient;
            _mapper = mapper;
        }
        public async Task<int> Handle(ReleaseAppointmentUpdateCommand request, CancellationToken cancellationToken)
        {
            ReleaseAppointment release = _mapper.Map<ReleaseAppointment>(request);
           return await _sqlSugarClient.Updateable(release).ExecuteCommandAsync();
        }
    }
}
